﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using FluentNHibernate;

namespace Mindfor.Web.Data.Mappings
{
	public class RoleMap : ClassMap<Role>
	{
		public RoleMap()
		{
			Table("Roles");
			Id(m => m.Id);
			Map(m => m.Name).Length(255).Not.Nullable();
			Map(m => m.FriendlyName).Length(255);
			Map(m => m.Description);
			
			HasManyToMany<User>(m => m.UsersInRole).Table("UserRoles").ParentKeyColumn("RoleId").ChildKeyColumn("UserId");
		}
	}
}
